from xmlrpc.server import SimpleXMLRPCServer


class Calculate(object):
    def add(self, x, y):
        return x + y

    def sub(self, x, y):
        return x - y

    def subtract(self, x, y):
        return abs(x - y)


obj = Calculate()
server = SimpleXMLRPCServer(("localhost", 8088))
# 将实例注册给rpc server
server.register_instance(obj)
print("listen at 8088")
server.serve_forever()
